const utils={
    randomNum(){
        return Math.floor(Math.random()*100)
    },
    randomArray(){
        return Array.from(Array(this.randomNum()),()=>this.randomNum())
    }
}

function quickSort(array){
    // 把最后的数作为基准
    // pivot 支点 
    if(array.length<=1){
        return array
    }

    let pivot = array[array.length-1]
    let left=array.filter((value,index)=>value<=pivot&&index!=array.length-1)
    let right=array.filter((value)=>value>pivot)
    return [...quickSort(left),pivot,...quickSort(right)]
}

console.log(quickSort(utils.randomArray()))